package cn.xscrum.vtsp.controller;


import cn.xscrum.common.core.controller.BaseController;
import cn.xscrum.vtsp.service.IVtspActivityStatisticService;
import cn.xscrum.vtsp.service.IVtspVisualService;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 活动统计分析Controller
 *
 * @author wfs
 * @date 2021-10-06
 */

@Controller
@RequestMapping(value = "/vtsp/statistic/activitystatistic")
public class VtspActivityStatisticController extends BaseController
{

    //访问路径前缀
    private String prefix = "/vtsp/statistic/activitystatistic";

    @Autowired
    private IVtspActivityStatisticService activityStatisticService;

    @Autowired
    private IVtspVisualService visualService;

    /**
     * 请求地址为/vtsp/statistic/volunteerstatistic时跳转至/vtsp/statistic/volunteerstatistic/volunteerStatistic.html
     *
     * @return volunteerStatistic视图名
     */
    @RequiresPermissions("vtsp:statistic:activitystatistic:view")
    @GetMapping()
    public String volunteerStatistic()
    {
        return prefix + "/activityStatistic";
    }

    /**
     * 获取活动类型的分布
     *
     * @return 活动的类型名以及其对应的活动项数（已结项活动）的集合
     */
    @RequiresPermissions("vtsp:statistic:activitystatistic:view")
    @GetMapping("/getActivityTypeDistribution")
    @ResponseBody
    public List<Map<String,Object>> getActivityTypeDistribution()
    {
        return visualService.getActivityTypeVisual();
    }

    /**
     * 获取服务对象的国家分布情况
     *
     * @return 国家以及国家含有的服务对象的人数的集合
     */
    @RequiresPermissions("vtsp:statistic:activitystatistic:view")
    @GetMapping("/getServiceObjectLocalDistribution")
    @ResponseBody
    public List<Map<String,Object>> getServiceObjectLocalDistribution()
    {
        return activityStatisticService.getServiceObjectLocalDistribution();
    }

    /**
     * 获取活动状态的分布情况
     *
     * @return 各个活动状态以及其对应的活动数的集合
     */
    @RequiresPermissions("vtsp:statistic:activitystatistic:view")
    @GetMapping("/getActivityStatus")
    @ResponseBody
    public List<Map<String,Object>> getActivityStatus()
    {
        return activityStatisticService.getActivityState();
    }

    /**
     * 获取例年开展活动的分布趋势
     *
     * @return  每年以及其每年开展的活动数的集合
     */
    @RequiresPermissions("vtsp:statistic:activitystatistic:view")
    @GetMapping("/getActivityGrowthTrend")
    @ResponseBody
    public List<Map<String,Object>> getActivityGrowthTrend()
    {
        return activityStatisticService.getActivityGrowthTrend();
    }

    /**
     * 获取例年服务对象的人数增长趋势
     *
     * @return  每年以及其每年服务对象的人数的集合
     */
    @RequiresPermissions("vtsp:statistic:activitystatistic:view")
    @GetMapping("/getServiceObjectGrowthTrend")
    @ResponseBody
    public List<Map<String,Object>> getServiceObjectGrowthTrend()
    {
        return activityStatisticService.getServiceObjectGrowthTrend();
    }


    /**
     * 获取服务对象的年龄分布趋势
     *
     * @return  各个年龄段以及其对应的服务对象人数的集合
     */
    @RequiresPermissions("vtsp:statistic:activitystatistic:view")
    @GetMapping("/getServiceObjectAgeDistribution")
    @ResponseBody
    public List<Map<String,Object>> getServiceObjectAgeDistribution()
    {
        return activityStatisticService.getServiceObjectAgeDistribution();
    }

}
